import service from '@/utils/http';
import { ApiBase } from '@/types/api/apiBase';
import { AxiosPromise } from 'axios';

export function fetchCommit(
  type: number,
  task: Record<string, any> | Record<string, any>[] | undefined,
): AxiosPromise<ApiBase<null>> {
  return service('/task/commit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: {
      type,
      task,
    },
  });
}

/**
 * 开始挖矿
 * {"type":6,"task":[{"monitor":62,"miners":["00:30:18:54:08:F8"]}]}:
 */

/**
 * 重启矿机
 * {"type":1,"task":[{"monitor":62,"miners":["00:30:18:54:08:F8"]}]}:
 *
 * 关闭矿机
 * {"type":2,"task":[{"monitor":62,"miners":["00:30:18:54:08:F8"]}]}:
 */
